﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DevExpress.Xpf.LayoutControl;
using System.Diagnostics;

namespace nLearning.UC
{
    /// <summary>
    /// Interaction logic for ViewerHost.xaml
    /// </summary>
    public partial class ViewerHost : UserControl
    {
        public ViewerHost()
        {
            InitializeComponent();
        }

        public enum MediaType
        {
            Video,
            Audio,
            PDF,
            Presentation
        }

        private MediaType _inputType;
        private string _inputPath;

        public string InputPath
        {
            get { return _inputPath; }
            set { _inputPath = value; }
        }

        public MediaType InputType
        {
            get { return _inputType; }
            set { _inputType = value; }
        }


        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (_inputType == MediaType.Presentation)
            {
                string testPPT = @"C:\Users\Angolous\Documents\home.pptx";
                string appPath = LearningLib.ProgramFilesx86() + @"\Microsoft Office\Office14\PPTVIEW.EXE";
                string pptPath = "o:\\"+InputPath;
                Process pptProc = new Process();
                pptProc.StartInfo.FileName = appPath;
                pptProc.StartInfo.Arguments = "/f " + testPPT;
                pptProc.Start();
                pptProc.WaitForExit();
                btBack_Click(null, null);
            }
            //btBack.PreviewMouseDown += new MouseButtonEventHandler(btBack_PreviewMouseDown);
        }

        void btBack_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            int marginValue = 45;
            Thickness margin = frmHost.Margin;
            margin.Bottom = marginValue;
            margin.Left = marginValue;
            margin.Right = marginValue;
            margin.Top = marginValue;
            frmHost.Margin = margin;
        }

        private void btBack_Click(object sender, RoutedEventArgs e)
        {
            UC.Lecture lecture = new Lecture();
            lecture.LectureInfo = Warehouse.lecture_info;
            WpfPageTransitions.PageTransition transition = new WpfPageTransitions.PageTransition();
            transition.TransitionType = WpfPageTransitions.PageTransitionType.Slide;
            transition.ShowPage(lecture);
            Window.GetWindow(this).Content = transition;
        }

        private void container_Click(object sender, EventArgs e)
        {
            int marginValue = 45;
            Thickness margin = frmHost.Margin;
            margin.Bottom = marginValue;
            margin.Left = marginValue;
            margin.Right = marginValue;
            margin.Top = marginValue;
            frmHost.Margin = margin;
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            UC.Lecture lecture = new Lecture();
            lecture.LectureInfo = Warehouse.lecture_info;
            WpfPageTransitions.PageTransition transition = new WpfPageTransitions.PageTransition();
            transition.TransitionType = WpfPageTransitions.PageTransitionType.Slide;
            transition.ShowPage(lecture);
            Window.GetWindow(this).Content = transition;
        }
    }
}
